package com.yi.wood.web.ctrl;

import com.yi.wood.entity.AppUserAddress;
import com.yi.wood.web.service.AppUserAddressProService;
import lombok.extern.log4j.Log4j2;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author MoYi
 * create date 2019/4/14 18:03
 */
@Validated
@RestController
@RequestMapping(value = "/api/aua/")
@Log4j2
public class AppUserAddressCtrl extends BaseCtrl{

    @Resource
    private AppUserAddressProService appUserAddressProService;

    @RequestMapping(value = "/page", method = RequestMethod.GET)
    public Object pageAppUserAddressList(@RequestParam Long userId){
        return success(appUserAddressProService.findAddressByUserId(userId));
    }

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public Object addAppUserAddress(@RequestBody AppUserAddress appUserAddress){
        appUserAddressProService.addData(appUserAddress);
        return success();
    }

    @RequestMapping(value = "/del/{id}", method = RequestMethod.DELETE)
    public Object delAppUserAddress(@PathVariable Long id){
        appUserAddressProService.delData(id);
        return success();
    }

    @RequestMapping(value = "/update", method = RequestMethod.PUT)
    public Object updateAppUserAddress(@RequestBody AppUserAddress appUserAddress){
        appUserAddressProService.updateData(appUserAddress);
        return success();
    }
}

